package com.kingsoft.demo.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 业务代理类(JDK动态代理)
 * @author kbl
 *
 */
public class BusinessHandler implements InvocationHandler{

	private Object object = null;//代理目标

	public BusinessHandler(Object object) {
	   this.object = object;
	}


	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		
		System.out.println("do something before method");

		Object ret = method.invoke(this.object, args); //调用方法
		
		System.out.println(proxy.getClass());
		
		System.out.println("do something after method");

		return ret;
	} 

}
